<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
{insert name="module_cssjs" css="core.css" js=""}
<script type="text/javascript" src="{$_conf.static_server}/admin/JSWFUpload/jquery-1.4.2.min.js"></script>
<link href="{$_conf.static_server}/admin/JSWFUpload/css/vinSwfUpload-1.2-skin.css" rel="stylesheet" type="text/css"/>
<link href="{$_conf.static_server}/admin/JSWFUpload/css/vinSwfUpload-1.2.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="{$_conf.static_server}/admin/JSWFUpload/core/SWFUpload-2.2.js"></script>
<script type="text/javascript" src="{$_conf.static_server}/admin/JSWFUpload/vinSWFUpload-1.2.js"></script>
</head>
{literal}
<style type="text/css">
.image-list {
	margin-bottom: 5px;
}
#images {
	text-align: center;
	margin: 0;
	padding: 0;
	display: none;
	border: 1px solid #ccc;
	overflow: hidden;
	padding: 5px;
}
#images li {
	width: 110px;
	float: left;
	margin: 0;
	padding: 0;
	list-style:none;
}
#images img {
	width: 100px;
	padding: 2px;
	border: 1px solid #ccc;
}
.image-list .btn-box {
	clear: both;
	display: none;
	padding: 10px;
	border: 1px solid #ccc;
	border-top: none;
}
#vinEdit {
	width: 100%
}
#list-2 {
	display: none;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$('[name="images"]').submit(function() {
	var params = $('[name="images"]').serialize();
	$.post('/yunying/product/picture/add.json', params, function(dt) {
		if(dt.status) {
			alert(dt.message);
		} else {
			alert('保存图片成功');
			window.location.href = '/yunying/product/picture/?id={/literal}{$id}{literal}';
		}
	}, 'json')
	return false;
});
$('[name="del"]').click(function() {
	var $this = this;
	var id = $(this).parents('tr').attr('node-id');
	if(!id) {
		alert('缺少参数');return ;
	}
	if(!confirm('您确定删除此图片吗？'))return ;
	
	var params = {'id': id};
	$.post('/yunying/product/picture/del.json', params, function(dt) {
		if(dt.status) {
			alert(dt.message);
		} else {
			$($this).parents('tr').remove();
		}
	}, 'json');
});
$('[name="logo"]').click(function() {
	var $this = this;
	var id = $(this).attr('id');
	var path = $(this).attr('path');
	if(!path) {
		alert('图片地址错误');return ;
	}
	if(!id) {
		alert('缺少景点ID');return ;
	}
	if(!confirm('您确定设置此图片为景点logo吗？'))return ;
	
	var params = {'id': id, image: path};
	$.post('/yunying/product/logo.json', params, function(dt) {
		if(dt.status) {
			alert(dt.message);
		} else {
			alert('设置景点logo成功');
			window.location.href = '/yunying/product/picture/?id={/literal}{$id}{literal}';
		}
	}, 'json');
});
$('[name="upload"]').click(function() {
	$('#list-1').hide();
	$('#list-2').show();
	$(this).parents('strong').attr("class", 'on').siblings().removeClass('on');
});

var path = "{/literal}{$_conf.static_server}{literal}/admin/JSWFUpload/";
var upload = $("#vinEdit").vinSWFUpload( {
	uploadURL:'{/literal}{$_conf.server}{literal}/upload/?app={/literal}{$app}{literal}&hash={/literal}{$hash|urlencode}{literal}',
	width : "100%",
	heigth : 300,
	sizeUnit:"M",
	skin:"green",
	autoRemoveStoped:false,
	flashURL : path+"core/SWFUpload.swf",
	addImgURl:path+"images/add.gif",
	uploadImgURl:path+"images/upload.png",
	stopImgURl:path+"images/stop.png",
	deleteImgURl:path+"images/trash.gif",
	tipImgURl:path+"images/tip.gif"
});
});

</script>
{/literal}
<body>
<h3 class="label">
	{include file="module/module_ticket.html" flag="picture" id=$id}
	<span class="refresh"><a href="/yunying/product/">返回列表</a></span>
	<span class="refresh"><a href="">刷新</a></span>
</h3>

<div class="table">
	<div class="desc">当前景点：{$info.name}【{$info.province|intToProvinceName} {$info.city|intToCityName:$info.province} {$info.location}】</div>
	<h3 class="label" style="border: 1px solid #E4E4E4">
		<strong class="on"><span><a href="/yunying/product/picture/?id={$id}">图片列表</a></span></strong>
		<strong><span><a name="upload" href="javascript:void(0);">上传图片</a></span></strong>
	</h3>
	<div id="list-1">
	<table class="TB-list">
		{foreach item=item key=key from=$picture.data name=list}
		<tr {if $smarty.foreach.list.index%2 == 0}class="even"{else}class="odd"{/if} node-id={$item.id}>
			<td>{$item.id}</td>
			<td><img width="70" height="70" src="{$_conf.data_server}/{$item.path}" /></td>
			<td>
				{if $item.path == $info.image}
				[景点logo]
				{else}
				[<a href="javascript:void(0);" id="{$info.id}" path="{$item.path}" name="logo">设为景点logo</a>]
				{/if}
				[<a href="javascript:void(0);" name="del">删除</a>]
			</td>
		</tr>
		{/foreach}
	</table>
	<div>{insert name="module_page" query=$query size=$picture.size num=$picture.num page=$picture.page}</div>
	</div>
	<div id="list-2">
	<div class="image-list">
		<form action="" name="images">
		<input name="id" type="hidden" value="{$id}" />
		<ul id="images">
			
		</ul>
		<div class="btn-box" id="btn-box">
			<span class="btn-indent"><input class="btn" type="submit" value="保&nbsp;&nbsp;存&nbsp;&nbsp;图&nbsp;&nbsp;片" /></span>
		</div>
		</form>
	</div>
	<div id="vinEdit"></div>
	</div>
</div>
</body>
</html>